<template>
  <div class="app-container">
    <el-form  class="search-form-new" :model="queryParams" ref="queryForm" :inline="true" v-show="showSearch" label-width="60px">
      <el-form-item label="标题" prop="noticeTitle">
        <el-input v-model="queryParams.noticeTitle" placeholder="请输入关键字" clearable />
      </el-form-item>
      <!-- <el-form-item label="操作人员" prop="createBy">
        <el-input
          v-model="queryParams.createBy"
          placeholder="请输入操作人员"
          clearable
        />
      </el-form-item>
      <el-form-item label="类型" prop="noticeType">
        <el-select v-model="queryParams.noticeType" placeholder="公告类型" clearable size="small">
          <el-option
            v-for="dict in dict.type.sys_notice_type"
            :key="dict.value"
            :label="dict.label"
            :value="dict.value"
          />
        </el-select>
      </el-form-item> -->
      <el-form-item class="btns">
        <el-button type="primary" icon="el-icon-search" @click="handleQuery">搜索</el-button>
        <!-- <el-button type="warning" icon="el-icon-refresh" @click="resetQuery">重置</el-button> -->

      </el-form-item>
    </el-form>
    <div class="list_box">
      <ul v-if="noticeList&&noticeList.length">
        <li @click="openDetail(item)" class="flex alc" v-for="item in noticeList" :key="item.id">
          <i class="icon"></i>
          <span class="title">
            {{ item.noticeTitle }}
          </span>
        </li>
      </ul>
    </div>

    <!-- <div class="table_box">
      <el-table stripe v-loading="loading" :data="noticeList">

        <el-table-column label="标题" align="center" prop="noticeTitle" :show-overflow-tooltip="true" />

        <el-table-column label="发布时间" prop="createTime" width="160">
          <template slot-scope="scope">
            <span>{{ parseTime(scope.row.createTime, '{y}-{m}-{d}') }}</span>
          </template>
        </el-table-column>
        <el-table-column label="操作" class-name="small-padding fixed-width" width="200">
          <template slot-scope="scope">
            <el-button type="edit" icon="el-icon-edit" @click="handleUpdate(scope.row)" v-hasPermi="['system:notice:edit']">查看详情</el-button>
          </template>
        </el-table-column>
      </el-table>
    </div> -->

    <!-- 添加或修改公告对话框 -->
    <el-dialog :title="title" :visible.sync="open" width="980px" append-to-body>
      <div v-if="currentDetail" v-html="currentDetail">

      </div>
    </el-dialog>
  </div>
</template>

<script>
import {
  listNotice,
  getNotice,
  delNotice,
  addNotice,
  updateNotice,
  getsystemNotice,
} from "@/api/system/notice";
import { getUserProfile } from "@/api/system/user";
import myEditor from "@/components/WangEditor/index.vue";
import { getToken } from "@/utils/auth";
export default {
  name: "",
  components: {},
  data() {
    return {
      // 遮罩层
      loading: true,
      // 选中数组
      ids: [],
      // 非单个禁用
      single: true,
      // 非多个禁用
      multiple: true,
      // 显示搜索条件
      showSearch: true,
      // 总条数
      total: 0,
      // 公告表格数据
      noticeList: [],
      // 弹出层标题
      title: "",
      // 是否显示弹出层
      open: false,
      user: {},
      // 查询参数
      queryParams: {
        pageNum: 1,
        pageSize: 10,
        noticeType: "101",
        ststus: 0,
      },
      currentDetail: "",
    };
  },
  created() {
    // this.uploadImgUrl = process.env.VUE_APP_BASE_API + "/upload/video";
    // this.getUser();
    // this.headers = {
    //   token: "Bearer " + getToken(),
    //   Authorization: "Bearer " + getToken(),
    // };
    this.getList();
  },
  methods: {
    handleEnter(event){
      event.preventDefault()
    },
    /** 查询 帮助中心列表 */
    getList() {
      this.loading = true;
      getsystemNotice(this.queryParams).then((response) => {
        this.noticeList = response.data;
        // this.total = response.total;
        this.loading = false;
      });
    },
    // 打开详情
    openDetail(item) {
      console.log("%c Line:133 🍯 item", "color:#4fff4B", item);
      this.currentDetail = "";
      this.title = item.noticeTitle
      if (item.noticeContent) {
        this.currentDetail = item.noticeContent;
        this.open = true;
      }
    },

    /** 搜索按钮操作 */
    handleQuery() {
      this.queryParams.pageNum = 1;
      this.getList();
    },
    /** 重置按钮操作 */
    resetQuery() {
      this.resetForm("queryForm");
      this.handleQuery();
    },
  },
};
</script>

<style scoped lang="scss">
.list_box {
  ul {
    padding: 15px;
    background: #f7f7f7;
    border-radius: 10px;
  }
  li {
    list-style-type: none;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    cursor: pointer;
    line-height: 2em;
    font-size: 15px;
    padding-left: 15px;
    border-radius: 4px;
    i {
      width: 5px;
      height: 5px;
      background: #333;
      margin-right: 5px;
      border-radius: 50%;
    }
    .title {
      color: #333;
    }
    &:hover {
      background-color: #6C5DD3;
      .title {
        color: #fff;
      }
      i{
        background-color:#fff;
      }
    }
  }
}
</style>